<?php

namespace Portal\Controller;
use Common\Controller\HomebaseController;

class ListController extends HomebaseController {

	// 前台文章列表
	public function index() {

		$term_id=I('get.id',0,'intval');
		$term=sp_get_term($term_id);

		if(empty($term)){
			header('HTTP/1.1 404 Not Found');
			header('Status:404 Not Found');
			if(sp_template_file_exists(MODULE_NAME."/404")){
				$this->display(":404");
			}
			return;
		}

		$tplname=$term["list_tpl"];
		$tplname=sp_get_apphome_tpl($tplname, "list");
		$this->assign($term);
		$this->assign('cat_id', $term_id);
		$this->display(":$tplname");
	}
//    视频新闻栏目
    public function newsvideo(){
//        echo "<pre>";
//        print_r($all_video);
        $count = M("videos")->count();
        $page = $this->page($count, 5);
        $this->assign("page", $page->show('Admin'));

        $all_video=M("videos")->order("create_time desc")->limit($page->firstRow , $page->listRows)->select();

        $this->assign('allvideo',$all_video);
        $this->display("newsvideo");

    }
	// 文章分类列表接口,返回文章分类列表,用于后台导航编辑添加
	public function nav_index(){
		$navcatname="文章分类";
		$term_obj= M("PortalTerms");

		$where=array();
		$where['status'] = array('eq',1);
		$terms=$term_obj->field('term_id,name,parent')->where($where)->order('term_id')->select();
		$datas=$terms;
		$navrule = array(
			"id"=>'term_id',
			"action" => "Portal/List/index",
			"param" => array(
				"id" => "term_id"
			),
			"label" => "name",
			"parentid"=>'parent'
		);
		return sp_get_nav4admin($navcatname,$datas,$navrule) ;
	}
}
